package com.reg.nstreg;

import java.io.IOException;

import okhttp3.Response;
import okhttp3.ResponseBody;
import okio.GzipSource;
import okio.Okio;

public class GZipper {
    public static String mo;
    public static String s;
    public static String u;

    static {
        GZipper.mo = "m o   b".replaceAll(" ", "");
        GZipper.s = "S H A- 2 5  6".replaceAll(" ", "");
        GZipper.u = " U   T F  - 8 ".replaceAll(" ", "");
    }

    public GZipper() {
        super();
    }

    public static String decodeBody(Response arg2) throws IOException {
        ResponseBody v0 = arg2.body();
        if(v0 == null) {
            return null;
        }

        if(GZipper.isZipped(arg2)) {
            return GZipper.unzip(arg2.body());
        }

        return v0.string();
    }

    public static boolean isZipped(Response arg1) {
        return "gzip".equalsIgnoreCase(arg1.header("Content-Encoding"));
    }

    public static String unzip(ResponseBody arg1) {
        try {
            return Okio.buffer(new GzipSource(arg1.source())).readUtf8();
        }
        catch(IOException e) {
            return null;
        }
    }
}

